package es.cazadoresmadridejos.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.springframework.web.multipart.commons.CommonsMultipartFile;

@Entity(name="Photo")
@Table(name="foto")
public class Photo extends BaseEntity {

	private static final long serialVersionUID = -2334379501208944632L;
	
	public enum PhotoType{
		TROFEO,MONTERIA,CAZA_MENOR
	}
	
	private Partner partner;
	private String url;
	private String description;
	private PhotoType type;
	private CommonsMultipartFile  file;
	
	@ManyToOne(optional=false)
	@JoinColumn(name="usuario")		
	public Partner getPartner() {
		return partner;
	}
	public void setPartner(Partner partner) {
		this.partner = partner;
	}
	@Column(name="url")
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	
	@Column(name="texto")
	public String getDescription() {
		return description;
	}
	public void setDescription(String descripion) {
		this.description = descripion;
	}
	
	@Column(name="tipo")
	@Enumerated(EnumType.STRING)
	public PhotoType getType() {
		return type;
	}
	public void setType(PhotoType type) {
		this.type = type;
	}

	@Transient
	public CommonsMultipartFile getFile() {
		return file;
	}
	public void setFile(CommonsMultipartFile file) {
		this.file = file;
		this.url = file.getOriginalFilename();
	}
	
}

